/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.tnmk.worktime.gui.utils;

import java.awt.Component;
import java.awt.Toolkit;
import java.awt.Window;

/**
 *
 * @author Administrator
 */
public class WindowUtils {

  public static void setCenter(Window frm) {
    frm.setLocationRelativeTo(null); //This will center your JFrame
  }

  public static void setRight(Component frm) {
    int x = getRightX(frm);
    int y = 0;
    frm.setLocation(x, y);
  }

  public static void setBottomRight(Component frm) {
    int x = getRightX(frm);
    int y = getBottomY(frm);
    frm.setLocation(x, y);
  }
public static int getCenterX(Component frm) {
    return (Toolkit.getDefaultToolkit().getScreenSize().width - (int) frm.getPreferredSize().getWidth())/2;
  }
  public static int getCenterY(Component frm) {
    return (Toolkit.getDefaultToolkit().getScreenSize().height - (int) frm.getPreferredSize().getHeight())/2;
  }

  public static int getBottomY(Component frm) {
    return (Toolkit.getDefaultToolkit().getScreenSize().height - (int) frm.getPreferredSize().getHeight() - 30);
  }

  public static int getRightX(Component frm) {
    return (Toolkit.getDefaultToolkit().getScreenSize().width - (int) frm.getPreferredSize().getWidth() - 10);
  }
}
